package com.google.code.jholidays.plugins.easter;

import com.google.code.jholidays.core.EventDescriptor;
import com.google.code.jholidays.events.AbstractEvent;
import com.google.code.jholidays.events.IEvent;
import com.google.code.jholidays.events.IFactory;

public class EasterFactory implements IFactory {

    @Override
    public IEvent createEvent(EventDescriptor descriptor, IEvent parent) {
	EasterProperties properties = new EasterProperties(descriptor);
	AbstractEvent event = new Easter(properties);
	return event;
    }

    @Override
    public boolean matches(EventDescriptor descriptor) {
	boolean result = false;

	if (descriptor != null) {
	    String expression = descriptor.getExpression();

	    if (expression != null && expression.equals(exactMatch))
		result = true;
	}

	return result;
    }

    static final String exactMatch = "%%estr";
}
